package leetcode_401_500;

import java.util.Arrays;

public class LeeCode_414 {
    public static void main(String[] args) {

    }
    private static int thirdMax(int[] nums) {
        Arrays.sort(nums);
        int k = 1;
        int index = nums.length - 2;
        while (index >= 0){
            if (nums[index] != nums[index + 1]){
                k++;
            }
            if (k == 3){
                return nums[index];
            }
            index--;
        }
        return nums[nums.length - 1];
    }
}
